#!/usr/bin/env python3
import jwt
from datetime import datetime, timedelta
import sys

# JWT配置（需要与Flask应用保持一致）
SECRET_KEY = 'your-secret-key-here'  # 这个需要与app中的SECRET_KEY一致
ALGORITHM = 'HS256'

def generate_simple_token(user_id, expires_hours=24):
    """生成简单的JWT token"""
    payload = {
        'user_id': str(user_id),
        'exp': datetime.utcnow() + timedelta(hours=expires_hours),
        'iat': datetime.utcnow()
    }
    
    token = jwt.encode(payload, SECRET_KEY, algorithm=ALGORITHM)
    return token

if __name__ == '__main__':
    if len(sys.argv) > 1:
        try:
            user_id = int(sys.argv[1])
        except ValueError:
            print("Invalid user ID provided. Please provide an integer.")
            sys.exit(1)
    else:
        user_id = 38
    
    token = generate_simple_token(user_id)
    print(f"Generated token for user {user_id}: {token}") 